<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>登陆</title>
  <link rel="stylesheet" href="/assets/layui/css/layui.css">
  <link rel="stylesheet" href="/admin/css/common.css">
  <link rel="stylesheet" href="/admin/css/login.css">
</head>
<body>

  <div class="login-main">
    <div class="login-head">
      <h2>网站内容管理系统</h2>
    </div>

    <form action="" class="layui-form user-login-body" method="post">
      <div class="layui-form-item">
        <label class="user-login-icon layui-icon layui-icon-username" for="user-login-username"></label>
        <input type="text" id="user-login-username" name="username" lay-verify="required" lay-reqtext="用户名不能为空" autocomplete="off" placeholder="用户名" class="layui-input">
      </div>
      <div class="layui-form-item">
        <label class="user-login-icon layui-icon layui-icon-password" for="user-login-password"></label>
        <input type="password" name="password" id="user-login-password" lay-verify="required" lay-reqtext="密码不能为空" placeholder="密码" autocomplete="off" class="layui-input">

      </div>
      <div class="layui-form-item">
        <button class="layui-btn layui-btn-fluid" lay-submit  lay-filter="adminLogin">立即提交</button>
      </div>

    </form>
  </div>

  <div class="layui-trans user-login-footer">
    <p>© 2019 <a href="https://gitee.com/gas0324/ascms" target="_blank">Asd</a></p>
  </div>


<script src="/assets/layui/layui.js"></script>
<script type="text/javascript">
  layui.use(['form','jquery'], function(){
    var form = layui.form;
    var $ = jQuery = layui.$;

    form.on('submit(adminLogin)', function(obj){
      $.post(
        './login',
        obj.field,
        function(res){
        
          if(res.code == "0"){
            //登入成功的提示与跳转
            layer.msg('登陆成功', {
              // offset: '15px',
              icon: 1,
              time: 1000
            }, function(){
              location.reload();
            });
          }else{
            layer.msg('用户名或密码不正确', {
              // offset: '15px',
              icon: 2,
              time: 1000
            })
          }
        },
        'json'

      );
      return false;
    })
  });
</script>
</body>
</html>